package com.w2cx.selenium.business;

import com.w2cx.selenium.base.DriverBase;
import com.w2cx.selenium.operate.VideoReviewOperate;
import org.openqa.selenium.WebElement;

import java.util.List;

public class VideoReviewProcess {

    DriverBase driver;
    VideoReviewOperate vrh;
    String ID;
    public VideoReviewProcess(DriverBase driver){
        this.driver = driver;
        vrh = new VideoReviewOperate(driver);
    }

    //视频审核
    public void videoReview(String introduction){
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //点击内容审核菜单
        vrh.clickContentReviewMenu();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击视频审核菜单
        vrh.clickVideoReviewMenu();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //获取第一条ID
        ID = vrh.getFirstVideoID().getText();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击去审核
        vrh.clickToReviewBtn();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //输入内容简介
        vrh.sendContentIntroduction(introduction);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //点击发布
        vrh.clickReleaseBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }






    }

    //断言
    public boolean videoReviewSuccess(){
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        List<WebElement> list = vrh.getUnReviewVideoList();
        for (int i=0;i<list.size();i++){
            if(list.get(i).getText().contains(ID)){
                return false;
            }
        }
        return true;
    }



}
